package com.crm.business.crm.controller;


import com.crm.business.crm.service.ICrmRoiStatisService;
import com.crm.business.crm.service.ICrmRoiYearStatisService;
import com.crm.common.crm.entity.BO.CrmRoiPutinPageBO;
import com.crm.common.ka.core.common.R;
import com.crm.common.ka.core.common.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 * 投放统计表 前端控制器
 * </p>
 *
 * @author zhangzhiwei
 * @since 2020-05-21
 */
@RestController
@RequestMapping("/crmRoiStatis")
@Api(tags = "投放统计模块接口")
public class CrmRoiStatisController {

    @Autowired
    private ICrmRoiStatisService crmRoiStatisService;
    @Autowired
    private ICrmRoiYearStatisService crmRoiYearStatisService;

    @PostMapping("/statisRoi")
    @ApiOperation("统计ROI数据")
    public Result statisRoi(){
        crmRoiStatisService.statisRoi();
        return R.ok();
    }

    /**
     * 查询ROI统计
     * @param crmRoiPutinPageBO
     * @return
     */
    @PostMapping("/queryAllRoiStatis")
    public Result queryAllRoiStatis(@RequestBody CrmRoiPutinPageBO crmRoiPutinPageBO){
        return R.ok(crmRoiStatisService.queryAllRoiStatis(crmRoiPutinPageBO));
    }

    /**
     * ROI统计明细列表
     * @param crmRoiPutinPageBO
     * @return
     */
    @PostMapping("/roiDetailBySource")
    public Result roiDetailBySource(@RequestBody CrmRoiPutinPageBO crmRoiPutinPageBO){
        return R.ok(crmRoiStatisService.queryPutinStatisForSource(crmRoiPutinPageBO));
    }

    /**
     * 预计收益统计查询
     * @return
     */
    @PostMapping("/projectedRevenueStatis")
    public Result projectedRevenueStatis(@RequestBody CrmRoiPutinPageBO crmRoiPutinPageBO){
        return R.ok(crmRoiStatisService.projectedRevenueStatis(crmRoiPutinPageBO));
    }

    /**
     * ROI月度统计
     * @param crmRoiPutinPageBO
     * @return
     */
    @PostMapping("/roiStatisForMonth")
    public Result roiStatisForMonth(@RequestBody CrmRoiPutinPageBO crmRoiPutinPageBO){
        return R.ok(crmRoiStatisService.roiStatisForMonth(crmRoiPutinPageBO));
    }

    /**
     * 客单价月度统计
     * @param crmRoiPutinPageBO
     * @return
     */
    @PostMapping("/priceStatisForMonth")
    public Result priceStatisForMonth(@RequestBody CrmRoiPutinPageBO crmRoiPutinPageBO){
        return R.ok(crmRoiStatisService.priceStatisForMonth(crmRoiPutinPageBO));
    }

    /**
     * ROI年度统计
     * @param crmRoiPutinPageBO
     * @return
     */
    @PostMapping("/roiStatisForYear")
    public Result roiStatisForYear(@RequestBody CrmRoiPutinPageBO crmRoiPutinPageBO){
        return R.ok(crmRoiYearStatisService.roiStatisForYear(crmRoiPutinPageBO.getPutinPlatform()));
    }

    /**
     * 客单价年度统计
     * @param crmRoiPutinPageBO
     * @return
     */
    @PostMapping("/priceStatisForYear")
    public Result priceStatisForYear(@RequestBody CrmRoiPutinPageBO crmRoiPutinPageBO){
        return R.ok(crmRoiYearStatisService.priceStatisForYear(crmRoiPutinPageBO.getPutinPlatform()));
    }

}
